{extend name="common/base"}
{block name="page-content-main"}
<div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
    <div class="am-form-group">
        <div class="am-btn-toolbar">
            <div class="am-btn-group am-btn-group-xs">
                <a class="am-btn am-btn-default am-btn-success am-radius btn-open-frame"
                   data-href="{$add_url}" data-title="新增价格">
                    <span class="am-icon-plus"></span> 新增
                </a>
            </div>
        </div>
    </div>
</div>
<div class="am-u-sm-12">
    <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black">
        <thead>
        <tr>
            <th>ID</th>
            <th>来源角色</th>
            <th>目标角色</th>
            <th>价格</th>
            <th>有效期(秒)</th>
            <th>截止日期</th>
            <th>添加时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo" empty="<tr><td colspan='8' class='am-text-center'>暂无记录</td></tr>"}
        <tr>
            <td class="am-text-middle">{$vo.id}</td>
            <td class="am-text-middle">{$vo.source.title}</td>
            <td class="am-text-middle">{$vo.target.title}</td>
            <td class="am-text-middle">{$vo.price}</td>
            <td class="am-text-middle">{$vo.valid_seconds}</td>
            <td class="am-text-middle">{$vo->deadline->format('Y-m-d H:i:s')}</td>
            <td class="am-text-middle">{$vo.create_at->format('Y-m-d H:i')}</td>
            <td class="am-text-middle">
                <div class="tpl-table-black-operation">
                    <a data-href="{:url($edit_uri, ['id' => $vo['id']])}" class="btn-open-frame" data-title="编辑价格">
                        <i class="am-icon-pencil"></i> 编辑
                    </a>
                    <a href="javascript:;" class="item-delete tpl-table-black-operation-del"
                       data-id="{$vo.id}">
                        <i class="am-icon-trash"></i> 删除
                    </a>
                </div>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
</div>
<div class="am-u-lg-12 am-cf">
    <div class="am-fr">{$list->render()}</div>
    <div class="am-fr pagination-total am-margin-right">
        <div class="am-vertical-align-middle">总记录：{$list->total()}</div>
    </div>
</div>
{/block}
{block name="js-run"}
<script>
    $(function(){
        $('.item-delete').delete('id', '{$del_url}', '确定要删除此转换规则吗？');
        $('.btn-open-frame').on('click', function(){
            $.open_frame($(this).data('title'), $(this).data('href'));
        });
    });
</script>
{/block}